package xyz.thoughtset.viewer.common.crud.api.controller;


import org.springframework.web.bind.annotation.*;

import java.util.LinkedHashMap;

@RestController
@RequestMapping("/q/")
public class QueryController extends CrudController {

//    @GetMapping(value = "findByPage/{subject}")
//    public Page findByPage(Page argpage, @RequestParam(required = false) LinkedHashMap<String, Object> searchMap
//            , @PathVariable("subject") String subject) {
//        if (ObjectUtils.isEmpty(argpage)) {
//            argpage = new Page<>();
//        }
//        return findQueryService(subject).searchPage(argpage, searchMap, subject);
//    }

    @GetMapping(value = "findList/{subject}")
    @ResponseBody
    public Object findList(@RequestParam(required = false) LinkedHashMap<String, Object> searchMap
            , @PathVariable("subject") String subject) {
        return findQueryService(subject,"list").selectList(searchMap);
    }

    @GetMapping(value = "findOne/{subject}")
    @ResponseBody
    public Object findOne(@RequestParam String pkey, @PathVariable("subject") String subject) {

        return findQueryService(subject,"one").selectDetail(pkey);
    }


}
